//
//  TargetView.m
//  eye_hunter
//
//  Created by cherry on 10-10-6.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TargetView.h"


@implementation TargetView

@synthesize target;
@synthesize isFound;

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        isFound = NO;
		[self setUserInteractionEnabled:YES];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
	if (!isFound) {
		self.image = [UIImage imageNamed:target.dustPic];
		((MissionView *)self.superview).remain -= 1;
		int remains = ((MissionView *)self.superview).remain;
		if (remains == 0) {
			UIAlertView *baseAlert = [[UIAlertView alloc] initWithTitle:@"Congratulations!!" message:@"ALL CLEAR!!!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK",nil];
			[baseAlert show];
			[baseAlert release];
		}
	}
}

- (void)dealloc {
	[target dealloc];
    [super dealloc];
}


@end
